﻿#region Using Directives

    using System;

    using Csla;

    using MarketPulse.BusinessLogic.Core;

#endregion

namespace MarketPulse.BusinessLogic.Common
{
    /// <summary>
    /// This class represents a read only instance of a Country within the system.
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.DataAccess.Factory.CountryFactory, MarketPulse.DataAccess.Factory", "FetchInfo")]
    public class CountryInfo : MarketPulseReadOnlyBase<CountryInfo>
    {

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private CountryInfo()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                /// <summary>
                /// Method used to retrieve a Country info object 
                /// </summary>
                /// <param name="guid">The guid of the Country info object to retrieve</param>
                /// <returns>The populated Country info object survey</returns>
                public static CountryInfo Get(Guid guid)
                {
                    return DataPortal.Fetch<CountryInfo>(new SingleCriteria<Guid>(guid));
                }

            #endregion

        #endregion

        #region Properties

                /// <summary>A human readable name for this Country/summary>
            public static PropertyInfo<string> CountryNameProperty = RegisterProperty<string>(p => p.CountryName);
            /// <summary>A human readable name for this Country</summary>
            public string CountryName
            {
                get { return GetProperty(CountryNameProperty); }
            }

            /// <summary>A human readable, localised name for this Country</summary>
            public static PropertyInfo<string> LocalCountryNameProperty = RegisterProperty<string>(p => p.LocalCountryName);
            /// <summary>A human readable, localised name for this Country</summary>
            public string LocalCountryName
            {
                get { return GetProperty(LocalCountryNameProperty); }
            }

            /// <summary>Two character ISO code for the Country</summary>
            public static PropertyInfo<string> CountryISOCode2Property = RegisterProperty<string>(p => p.CountryISOCode2);
            /// <summary>Two character ISO code for the Country</summary>
            public string CountryISOCode2
            {
                get { return GetProperty(CountryISOCode2Property); }
            }

            /// <summary>Three character ISO code for the Country</summary>
            public static PropertyInfo<string> CountryISOCode3Property = RegisterProperty<string>(p => p.CountryISOCode3);
            /// <summary>Three character ISO code for the Country</summary>
            public string CountryISOCode3
            {
                get { return GetProperty(CountryISOCode3Property); }
            }

        #endregion
    }
}
